/*
 * @Date: 2023-01-22 02:17:37
 * @LastEditors: 恶名扬 2080156129@qq.com
 * @LastEditTime: 2023-01-24 05:39:19
 * @FilePath: \campus-repair-platform\server\routes\reception\feedback.js
 */
const express = require("express")
// 创建路由对象
const router = express.Router()

const feedbackService = require("../../service/reception/feedback")
// 导入验证表单数据的中间件
const expressJoi = require('@escook/express-joi')
// 导入需要的验证规则对象
const { submit_schema } = require("../../schema/reception/feedback")

router.use((req, res, next) => {
  if (req.auth?.type === 1 || req.auth?.type === 2) next() // pass control to the next handler
  else return res.errSend("没有权限访问", 10002)
})

// 提交意见反馈
router.post(
  "/",
  expressJoi(submit_schema),
  feedbackService.submitFeedback
)

module.exports = router
